﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace TrafficSimulation
{
    public class TrafficSimulation
    {
        private List<Cross> crosses = new List<Cross>();
        private List<Cars> cars = new List<Cars>();
        private List<Road> roads = new List<Road>();
        public List<Cell> cells = new List<Cell>();

        

        public Cell Cell
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
            }
        }

        public bool createItem(ItemTypes item)
        {
            return true;
        }
    
        public enum ItemTypes { BorderSideCar, BorderSideFree, Cross1, Cross2, RoadVertical, RoadHorizental, CurveTopRight, CurveTopLeft, CurveButtonRight, CurveButtonLeft };
        
        #region functions
        //public bool checkGrid
        public void getCell(Position pos)
        {

        }
        public void updateNeighbourCells()
        {

        }
        public void adjustGreenTime(int greenTime)
        {
            foreach (Cell c in cells)
            {
                if (!c.isCellEmpty())
                {
                    if (string.Compare(c.ItemType.ToString(),ItemTypes.Cross1.ToString())==0)
                    {
                        Crossing1 cross1 = new Crossing1();
                        cross1 = (Crossing1)c.getItem();
                        cross1.adjustCarGreenTrafficLight(greenTime);
                        cross1.ManageLights(greenTime);
                    }
                    else if (string.Compare(c.ItemType.ToString(),ItemTypes.Cross2.ToString())==0)
                    {
                        Crossing2 cross2 = new Crossing2();
                        cross2 = (Crossing2)c.getItem();
                        cross2.adjustCarGreenTrafficLight(greenTime);
                        cross2.ManageLights(greenTime);
                    }
                }   
            }
        }
        public bool checkPort(Position pos)
        { return true; }
        public bool disablePort(Cell c,Position pos)
        { return true; }


        public void setSpeed(int _speed)
        {
            speed = _speed;
        }

        #endregion


        public int speed { get; set; }
    }
}
